DECLARE @T TABLE (ID INT PRIMARY KEY IDENTITY(1,1), Test CHAR(1))


DECLARE @T2 TABLE (ID INT,Name VARCHAR(max))

INSERT INTO @T (Test) VALUES ('A'),('B')

INSERT INTO @T2 (ID, Name) VALUES (1,'MATT'),(1,'SEAN'),(2,'DAVE'),(2,'KIM'),(2,'MAGGIE')

SELECT  DB_ID() 
FROM	   @T AS T
	   CROSS APPLY (SELECT SubT.ID AS Detail, SubT.Name FROM @T2 AS SubT WHERE SubT.ID = T.ID) AS T2